<template>
     <div class="login-container">
        <div class="mask-base"></div>
       <div class="login-content">
         <div class="desc">
           欢迎使用管理系统
         </div>
         <div class="login-box">
           <h4 class="title">登陆</h4>
           <el-input placeholder="请输入账号"  v-model="name">
             <i slot="prefix" class="icon-denglu iconfont el-input__icon"></i>
           </el-input>
           <el-input placeholder="请输入密码" type="password"  v-model="pwd">
             <i slot="prefix" class="icon-denglu1 iconfont el-input__icon"></i>
           </el-input>
           <el-button type="primary" @click="handleCheck">登陆</el-button>
         </div>
       </div>
     </div>
</template>

<script>
import apiDataFilter from '../../utils/apiDataFilter'
import Cookies from 'js-cookie'
export default {
  name: 'login',
  data () {
    return {
      name: '',
      pwd: ''
    }
  },
  methods: {
    handleCheck () {
      if (!this.name) {
        this.$message.error('请输入账号');
        return
      }
      if (!this.pwd) {
        this.$message.error('请输入密码');
        return
      }
      this.submit()
    },
    submit () {
      let param = { autolg: 0, pwd: this.pwd, userName: this.name };
      apiDataFilter.request({
        apiPath: 'common.login',
        method: 'post',
        data: param,
        successCallback: (res) => {
          Cookies.set('Authorization', res.data, { expires: 7, path: '/' });
          this.$router.push('/manage/home')
        },
        errorCallback:(e)=>{
          this.$message.error(e)
        }
      })
    },
  },
  created () {

  }
}
</script>

<style scoped lang='less'>
    @import "login.less";
</style>
